//
//  HomeQuickInfoCell.m
//  Ginix
//
//  Created by 冯志强 on 2025/2/20.
//

#import "HomeQuickInfoCell.h"

@interface HomeQuickInfoCell()
@property (nonatomic,strong) UIImageView * bgView;
@property (nonatomic,strong) UILabel * nameLabel;
@property (nonatomic,strong) YYLabel * timeLabel;
//@property (nonatomic,strong)
@end

@implementation HomeQuickInfoCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    self.selectionStyle = UITableViewCellSelectionStyleNone;
}


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.backgroundColor = UIColor.clearColor;
        self.contentView.backgroundColor = UIColor.clearColor;
        [self setSubViewLayout];
    }
    return self;
}
-(void)setSubViewLayout{
    
    [self addSubview:self.bgView];
    [_bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_offset(CGSizeMake(333 * FMScaleX, 50 * FMScaleX));
        make.center.equalTo(@0);
    }];
    [self addSubview:self.nameLabel];
    [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_offset(12 * FMScaleX);
        make.height.mas_equalTo(20 * FMScaleX);
        make.centerX.equalTo(@0);
    }];
    [self addSubview:self.timeLabel];
    [_timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.nameLabel.mas_bottom).offset(3 * FMScaleX);
        make.centerX.equalTo(@0);
    }];
}

-(void)setInfoModel:(HomeQuickCheckModel *)infoModel type:(NSInteger)type{
        
    if (type == 0) {
        NSMutableAttributedString * attri = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@ 查看历史报告 >",infoModel.createTime] attributes:@{NSForegroundColorAttributeName:RDRGB(0x999999)}];
        [attri yy_setTextHighlightRange:[attri.string rangeOfString:@"查看历史报告 >"] color:RDRGB(0xAD7D62) backgroundColor:[UIColor clearColor] tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
            id vc = [[NSClassFromString(@"HealthReportsVC") alloc]init];
            [[UIViewController findNavigationController] pushViewController:vc animated:YES];
        }];
        self.timeLabel.attributedText = attri;
    }else{
        NSMutableAttributedString * attri = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@",infoModel.createTime] attributes:@{NSForegroundColorAttributeName:RDRGB(0x999999)}];;
        self.timeLabel.attributedText = attri;
    }
    
}

-(UIImageView *)bgView{
    
    if (!_bgView) {
        _bgView = [[UIImageView alloc]init];
        _bgView.image = [UIImage imageNamed:@"Home_list_title"];
    }
    return _bgView;
}
-(UILabel *)nameLabel{
    
    if (!_nameLabel) {
        _nameLabel = [[UILabel alloc]init];
        _nameLabel.font = Regular(20);
        _nameLabel.textColor = RDRGB(0x99674C);
        _nameLabel.text = @"快速健康检测报告";
    }
    return _nameLabel;
}
-(YYLabel *)timeLabel{
    
    if (!_timeLabel) {
        _timeLabel = [[YYLabel alloc]init];
        _timeLabel.textColor = RDRGB(0x999999);
        
        _timeLabel.font = Medium(10);
    }
    return _timeLabel;
}
@end
